import { http } from '@/utils/request'
import type { NoticeParams, NoticeList, QueryParams } from './type'

const prefix = import.meta.env.VITE_API_SYS

// 查询公告列表
export function listNotice(params: QueryParams & Page) {
	return http.get<ResPage<NoticeList[]>>(`${prefix}/notice/list`, params)
}

// 查询公告详细
export function getNotice(id: number) {
	return http.get<NoticeList>(`${prefix}/notice/${id}`)
}

// 新增公告
export function addNotice(data: NoticeParams) {
	return http.post(`${prefix}/notice`, data)
}

// 修改公告
export function updateNotice(data: NoticeParams) {
	return http.put(`${prefix}/notice`, data)
}

// 删除公告
export function delNotice(noticeId: string) {
	return http.delete(`${prefix}/notice/${noticeId}`)
}
